home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 45
/
Amiga Format CD45 (1999-09)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-11].iso
/
-serious-
/
misc
/
mcread
/
original
/
mbinary.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-08-09
|
1KB
|
53 lines
/* mcread: mbinary.c
Copyright (C) 1991, Mike Gleason Jr & NCEMRSoft.
All Rights Reserved. */
#include <stdio.h>
#include "mcread.h"
long CheckMBHeader(in, filetypestr)
FILE *in;
char *filetypestr;
/* See if this file is in MacBinary II format, and if it is, get
some information about the file. Either way, after calling
this routine the file pointer will be at the start of the
data fork. It returns the total number of bytes in the
data fork, or 0 if a mbh was not detected. */
{
register long dataforklen;
register short zero;
*filetypestr = '\0';
zero = getc(in);
if (zero != '\0') goto fail;
if (fseek(in, (long) 74, SEEK_SET)) goto fail;
zero = getc(in);
if (zero != '\0') goto fail;
if (fseek(in, (long) 83, SEEK_SET)) goto fail;
zero = getc(in);
if (zero != '\0') goto fail;
/* if we got this far, its gotta be macbinary. */
if (fseek(in, (long) 83, SEEK_SET)) goto fail;
dataforklen = (long) Getl(in);
if (fseek(in, (long) 65, SEEK_SET)) goto fail;
(void) fgets(filetypestr, 8, in);
filetypestr[4] = '\0';
(void) fseek(in, (long) 128, SEEK_SET);
return (dataforklen); /* We made it! */
fail:
(void) fseek(in, (long) 0, SEEK_SET);
return ((long) -1);
} /* CheckMBHeader */
/* eof */